node_id=0;
num_packets=$3;
interval=$4;
main_path=$5;
config_file=$6;
num_proposers=$7;
folder_id=$8;
diff_submit_per_wake=$9

all_folder="all/"
cpu_folder="cpu/"
lat_folder="lat/"

delimeter="/"
txt_postfix=".txt"
pidstat="pidstat"$txt_postfix;
top="top"$txt_postfix;



for ((i=$1; i < (($1+$2)) ; i++))
do
             pidstat_path=$main_path$folder_id$delimeter$cpu_folder$node_id$pidstat;
                 top_path=$main_path$folder_id$delimeter$cpu_folder$node_id$top;
    performance_file_name=$main_path$folder_id$delimeter$all_folder$node_id$txt_postfix;
        latency_file_name=$main_path$folder_id$delimeter$lat_folder$node_id$txt_postfix;

	echo $performance_file_name;
	
 	ssh -f -n "node"${i} "pidstat 1 |grep ring >> $pidstat_path";
    ssh -f -n "node"${i} "top -b -d 1 | grep ring >> $top_path";
    
    if((node_id==$2-1))
    	then 
    		ssh -f -n "node"${i} "/home/parisa/LCR-JOURNAL/svn/LCR/ring/ring $node_id $diff_submit_per_wake $interval $performance_file_name $config_file $num_proposers $latency_file_name";
    else
    	ssh -f -n "node"${i} "/home/parisa/LCR-JOURNAL/svn/LCR/ring/ring $node_id $num_packets $interval $performance_file_name $config_file $num_proposers $latency_file_name";
    fi
    
    ((node_id+=1))
done
